<!DOCTYPE html>
<html>
    
    <head>
        <meta charset="utf-8">
        <title>
            后台管理
        </title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="/admin/css/x-admin.css" media="all">
    </head>
    
    <body>
        <div class="x-body">
            <form class="layui-form" id="uploadForm" action="/admin/banner/update_list" method="POST" enctype="multipart/form-data">
                <div class="layui-form-item">
                    <label for="link" class="layui-form-label">
                        <span class="x-red">*</span>轮播图
                    </label>
                    <div class="layui-input-inline">
                      <div style="position:relative;">
                        <input  type="file" id="link" name="image" class="layui-input" onchange="preview(this)" style="opacity:0"/>
                        <div style="width:100px;height:30px;border:1px solid #ccc;position:absolute;top:3px;left:3px;z-index:-9999">
                        <div style="padding-left:12px;padding-top:5px">
                        <i class="layui-icon">&#xe62f;</i><span>&nbsp;图片上传</span>
                        </div>
                        </div>
                      </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label  class="layui-form-label">缩略图
                    </label>
                    <div id="preview"></div>
                </div>
                <div class="layui-form-item">
                    <label  class="layui-form-label">
                    </label>
                </div>
                <!-- <div class="layui-form-item">
                    <label for="link" class="layui-form-label">
                        <span class="x-red"></span>链接
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="link" name="link"  class="layui-input">
                    </div>
                </div> -->
                <div class="layui-form-item">
                    <label for="desc" class="layui-form-label">
                        <span class="x-red">*</span>描述
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="desc" name="state"  class="layui-input" placeholder="描述在20字以内">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label  class="layui-form-label"></label>
                    <input type="hidden" name="id" value="{php}echo $_GET['id'];{/php}" />
                    <button>更新</button>
                    <button  class="layui-btn"  type="button">
                       更新
                    </button>
                </div>
            </form>
        </div>
        <script src="/admin/lib/layui/layui.js" charset="utf-8">
        </script>
        <script src="/admin/js/x-layui.js" charset="utf-8">
        </script>
        <script type="text/javascript">
        function preview(file)  
        {  
        var prevDiv = document.getElementById('preview');  
        if (file.files && file.files[0])  
        {  
        var reader = new FileReader();  
        reader.onload = function(evt){  
        prevDiv.innerHTML = '<img style="width:100px;height:50px" src="' + evt.target.result + '" />';  
        }    
        reader.readAsDataURL(file.files[0]);  
        }  
        else    
        {  
        prevDiv.innerHTML = '<div class="img" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src=\'' + file.value + '\'"></div>';  
        }  
        }  
        </script>
        <script>
            layui.use(['form','layer'], function(){
              $ = layui.jquery;
              var form = layui.form()
              ,layer = layui.layer;

            });
        </script>
        <!-- ajax异步上传文件 -->
   <!--   <script type="text/javascript">
     function doUpload()
     {  
    	 if($("#link").val()==""){
    		 layer.msg("请选择文件",{icon:5});
    		 return false;
    	 }
    	 if($("#desc").val()==""){
    		 layer.msg("请添加描述",{icon:5});
    		 return false;
    	 }
         var formData = new FormData($("#uploadForm")[0]);
         $.ajax({  
              url: '/admin/banner/update_list', 
              type: 'POST',  
              data: formData,  
              async: true,  
              cache: false,  
              contentType: false,  
              processData: false,  
              success: function (msg){
            	//layer.alert(msg);
            	if(msg=="OK")
            	{
            		layer.confirm('添加成功!',{icon:6,btn:['继续添加','取消']}
            		,function()
            		{
            			location.reload();
            		}
            		,function()
            		{
            			var index = parent.layer.getFrameIndex(window.name);
                        //关闭当前iframe
                        parent.layer.close(index);	
                        parent.location.reload();
            		});
            	}
              }
              
              
         }); 
        
    }  
     </script> -->
    </body>
</html>